import 'package:flutter/material.dart';
import 'package:xiongan_app_yy/common/user_singleton.dart';
import 'package:xiongan_app_yy/entrys/rp/to_review_entity.dart';
import 'package:xiongan_app_yy/net/internet.dart';
import 'package:xiongan_app_yy/utils/toast_utils.dart';

//复核
class ToReviewProvider extends ChangeNotifier {
  
  // _netStatus系列表示请求状态：
  // false未请求
  // true请求中

  bool _netStatus1 = false;
  List _listData=List(); //列表数据

  bool _netStatus2 = false;
  ToReviewEntity detailListData=ToReviewEntity(); //详情列表数据

  //getter方法获取数据
  get netStatus1=>_netStatus1;
  get listData=>_listData;

  get netStatus2=>_netStatus2;


  //列表查询
  void getList({Map<String,dynamic> sendObj}) async {
    sendObj["warehouseid"] = DataSingleton().warehouseChoice.id;
    //sendObj["warehouseid"] = "a88638a710754671b4f460529f345764";
    //初始化数据和加载状态
    _netStatus1=true;
    _listData=[];
    notifyListeners();
    // print(DataSingleton().warehouseChoice.id);
    Map<String,dynamic> res = await Internet().get("WMS/MiWarehouseOutOrder/GetOutCheckOrderList",params:sendObj);
    if(res['flag'] == "success"){
      _listData=res['datas'];
    }else{
      TostUtil.showToast(res['msg']);
    }
    _netStatus1=false;
    notifyListeners();
  }

  //详情列表查询
  void getDetailListData({@required String orderid}) async {
    Map<String,dynamic> sendObj={
      "id":orderid
    };
    //初始化数据和加载状态
    _netStatus2=true;
    detailListData.datas=[];
    notifyListeners();
    Map<String,dynamic> res = await Internet().get("WMS/MiWarehouseOutOrder/GetOutOrderCheckDetailInfo",params:sendObj);
    if(res['flag'] == "success"){
      //_detailListData=res['datas'];
      detailListData=ToReviewEntity.fromJson(res['datas']);

    }else{
      TostUtil.showToast(res['msg']);
    }
    _netStatus2=false;
    notifyListeners();
  }
//提交
  Future<dynamic> SubmissionCheckDetail({Map sendObj}) async {
    print(sendObj.toString());
    Map<String,dynamic> res = await Internet().post("WMS/MiWarehouseOutOrder/SubmissionCheckDetail",params:sendObj);
    if(res['flag'] == "success"){
      TostUtil.showToast("提交成功");
    }else{
      TostUtil.showToast(res['msg']);
    }
    return res['datas'];
  }


}
